<?php

class ProductController extends Zend_Controller_Action
{
        public function init()
        {
        /* Initialize action controller here */
        }

        public function indexAction()
        {
//                $p=new Application_Model_Product();
//                $data=array();
//                for($i=1;$i<=9;$i++)
//                {
//                        $d=array(
//                                'id'=>$i,
//                                'name'=>'prod'.$i,
//                                'discripion'=>"desc$i",
//                                'category_id'=>1,
//                                'quantity'=>4,
//                                'price'=>$i,
//                                'image'=>"img$i.jpg"
//                        );
//                        //array_push($data,$d);
//                        $p->insert($d);
//                }
                //pre($data);
                $this->view->assign('data',$data);
        }
        
        public function showallAction(){
        $cat_id = $this->_getParam('cat_id');
        $product = new Application_Model_Product();
        $products = $product->getProducts($cat_id);
        $login = new Zend_Session_Namespace('login');
        $login->url = $this->view->url();
        $adapter = new Zend_Paginator_Adapter_Array($products);
        $paging = new Zend_Paginator($adapter);
        $paging->setItemCountPerPage(6);
        $page = $this->_request->getParam('page', 1);
        $paging->setCurrentPageNumber($page);
        $this->view->data = $paging;
        }

        public function showAction(){
        $pro_id = $this->_getParam('url');
        $product = new Application_Model_Product();
        $products = $product->getProduct($pro_id);
        $this->view->pro=$products;
        $login = new Zend_Session_Namespace('login');
        $login->url = $this->view->url();
        }
}

